package com.jy.modules.cims.component.common.service;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.jy.modules.cims.data.common.dao.TCMmBillParamDao;
import com.jy.modules.cims.data.common.dto.TCMmBillParamDTO;
import com.jy.platform.core.common.BaseDTO;

/**
 * @classname: TCMmBillParamService
 * @description: 定义  账单参数 实现类
 * @author:  JY-IT-D001
 */
@Service("com.jy.modules.cims.component.common.service.TCMmBillParamService")
public class TCMmBillParamService implements Serializable {

    private static final long serialVersionUID = 1L;
    
	@Autowired
	private TCMmBillParamDao dao;

	/**
     * @author JY-IT-D001
     * @description: 分页查询 账单参数列表
     * @date 2015-01-06 17:31:02
     * @param searchParams 条件
     * @return
     * @throws
     */ 
	public List<TCMmBillParamDTO> searchTCMmBillParamByPaging(Map<String,Object> searchParams) throws Exception {
		List<TCMmBillParamDTO> dataList =  dao.searchTCMmBillParamByPaging(searchParams);
		return dataList;
	}
	/**
     * @author JY-IT-D001
     * @description: 按条件查询账单参数列表
     * @date 2015-01-06 17:31:02
     * @param searchParams 条件
     * @return
     * @throws
     */
	public List<TCMmBillParamDTO> searchTCMmBillParam(Map<String,Object> searchParams) throws Exception {
	    List<TCMmBillParamDTO> dataList = dao.searchTCMmBillParam(searchParams);
        return dataList;
    }
	/**
     * @author JY-IT-D001
     * @description: 查询账单参数对象
     * @date 2015-01-06 17:31:02
     * @param id
     * @return
     * @throws
     */ 
	public TCMmBillParamDTO queryTCMmBillParamByPrimaryKey(String id) throws Exception {
		
		TCMmBillParamDTO dto = dao.findTCMmBillParamByPrimaryKey(id);
		
		if(dto == null) dto = new TCMmBillParamDTO();
		
		return dto;
		
	}

	/**
     * @title: insertTCMmBillParam
     * @author JY-IT-D001
     * @description: 新增 账单参数对象
     * @date 2015-01-06 17:31:02
     * @param dto
     * @return
     * @throws
     */
	@SuppressWarnings("all")
	public Long insertTCMmBillParam(TCMmBillParamDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		int count = dao.insertTCMmBillParam(paramMap);
		
		TCMmBillParamDTO resultDto = (TCMmBillParamDTO) paramMap.get("dto");
		Long keyId = resultDto.getId();
		return keyId;
	}
	/**
     * @title: updateTCMmBillParam
     * @author JY-IT-D001
     * @description: 修改 账单参数对象
     * @date 2015-01-06 17:31:02
     * @param paramMap
     * @return
     * @throws
     */
	public void updateTCMmBillParam(TCMmBillParamDTO dto) throws Exception {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", dto);
		
		dao.updateTCMmBillParam(paramMap);
	}
	/**
     * @title: deleteTCMmBillParamByPrimaryKey
     * @author JY-IT-D001
     * @description: 删除 账单参数,按主键
     * @date 2015-01-06 17:31:02
     * @param paramMap
     * @throws
     */ 
	public void deleteTCMmBillParamByPrimaryKey(BaseDTO baseDto,String ids) throws Exception {
		if(StringUtils.isEmpty(ids)) throw new Exception("删除失败！传入的参数主键为null");
		
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("dto", baseDto);
		paramMap.put("ids", ids);
		dao.deleteTCMmBillParamByPrimaryKey(paramMap);
	}

}

